// 数字滚动
var isStart = true
$(window).scroll(function () {
    var before = $(window).scrollTop();
    $(window).scroll(function () {
        var winHeight = $(window).height();
        var scrollTop = $(this).scrollTop();
        var IndexNumber = $('.IndexNumber').offset().top;
        if (before > scrollTop) {
            if (scrollTop <= 100) {
                isStart = true
            }
        };
        if (before < scrollTop) {
            if (winHeight + scrollTop >= IndexNumber + 150) {
                $('.content .item span').addClass('num')
                if (isStart) {
                    isStart = false
                    $(".IndexNumber .item").each(item => {
                        var text = $(".IndexNumber .item").eq(item).find('.num').text()
                        $(".IndexNumber .item").eq(item).find('.num').numberRock({
                            lastNumber: text,		//终止数字
                            duration: 800,
                            easing: 'swing',  	//慢快慢
                        });
                    });
                }

            }
        }
    });
});
(function ($) {
    $.fn.numberRock = function (options) {
        var defaults = {
            lastNumber: 100,
            duration: 2000,
            easing: 'swing'  //swing(默认 : 缓冲 : 慢快慢)  linear(匀速的)
        };
        var opts = $.extend({}, defaults, options);
        $(this).animate({
            num: "numberRock",
        }, {
            duration: opts.duration,
            easing: opts.easing,
            complete: function () {
                console.log("success");
            },
            step: function (a, b) {  //可以检测我们定时器的每一次变化
                $(this).html(parseInt(b.pos * opts.lastNumber));
            }
        });
    }
})(jQuery);